
cmake_minimum_required(VERSION 3.20.0)

project (MyMath VERSION 1.0.0)

add_library(${PROJECT_NAME} STATIC MyMath.cpp)

list(APPEND MyMath_header_file_list MyMath.h)
#target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

#install(FILES ${PROJECT_NAME}_header_file_list DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(FILES ${MyMath_header_file_list} DESTINATION include)
#set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER ${MyMath_header_file_list})

install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets
	LIBRARY DESTINATION lib
	ARCHIVE DESTINATION lib 
	RUNTIME DESTINATION bin
)


include(CMakePackageConfigHelpers)
write_basic_package_version_file(
    ${PROJECT_NAME}ConfigVersion.cmake
    VERSION ${PACKAGE_VERSION}
    COMPATIBILITY AnyNewerVersion 
)

install(EXPORT ${PROJECT_NAME}Targets
    FILE ${PROJECT_NAME}Targets.cmake
    DESTINATION lib/cmake/${PROJECT_NAME})

include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake INSTALL_DESTINATION lib/cmake/${PROJECT_NAME})

install(
    FILES 
    ${CMAKE_CURRENT_BINARY_DIR}/MyMathConfig.cmake
    ${CMAKE_CURRENT_BINARY_DIR}/MyMathConfigVersion.cmake
    DESTINATION 
    lib/cmake/${PROJECT_NAME}
)

add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} --install ${CMAKE_CURRENT_BINARY_DIR})
